class AdjMatrix:
    def __init__(self) -> None:
        self.matrix = []
        self.nr_state = 0

    def expand_matrix(self, size):
        for i in range(size - self.nr_state):
            self.matrix.append({})
        self.nr_state = size

    def __getitem__(self, id):
        if id >= self.nr_state:
            self.expand_matrix(id + 1)
        res = self.matrix[id]
        return res

    def __len__(self):
        return len(self.matrix)

    def show(self):
        print(self.matrix)
